<template>
	<view class="content">
		<heade title="详情" cross bg_color="bg_fff"></heade>
		<view class="">
			<view class="bg_F3F2F7 p-t10 p-b10 p-l15 p-r15 f-s15">{{Name}}</view>
			<view class="bg_fff p-t10">
				<view class="d-flex  align-center p-l15 p-r15 f-s14 ">
					<view class="co_666">销售单位:</view>
					<view class="d-flex align-center">
						<view v-for="(item,i) in list" @tap="unitsClick(i)" class="daiClass d-flex align-center justify-content-center border-radius-8 m-l10" :class="count ==i?'countClass':''">{{item.UnitName}}</view>
					</view>
				</view>
				<view class="d-flex align-center justify-content-space-between p-l15 p-r15 m-t20 p-b14">
					<!-- <view class="d-flex align-items-start justify-content-space-between m-r15  flex1">
						<text class="f-s14">仓库：</text>
						<picker @change="bindPickerChange" class="flex1" :value="index" :range="array" range-key="Name">
							<view class="d-flex align-center justify-content-space-between p-b3" style="border-bottom: 2rpx solid #999;width: 220rpx;">
								<view class="uni-input f-s14 f-w500 p-l10">{{array[index].Name}}</view>
								<text class="iconfont icon-sanjiaoxing f-s8 m-r5 co_666"></text>
							</view>
						</picker>
					</view> -->
					<view class=" d-flex align-items-start">
						<view class="d-flex position-relative">
							<view class="m-l3 position-absolute" style="color: red;top: 60%;transform: translate(0,-50%);left: 6rpx;">*</view>
							<text class="m-l20 f-s14">数量：</text>
						</view>
						<view class="p-b5 p-l5" style="width: 170rpx;border-bottom: 2rpx solid #999;width: 220rpx;">
							<input type="digit" v-model="number" class="f-s14 f-w500  box_box"  placeholder="请输入"> 
						</view>
					</view>
				</view>
			</view>
			<view class=" bg_fff m-t8 p-t10 p-b10">
				<view class="d-flex align-center p-l12">
					<view class="d-flex align-center justify-content-start p-b5">
						<checkbox value="cb" :checked="IsPresent" @click="IsPresent = !IsPresent"  style="transform:scale(0.7);" />
						<view class="m-l5 f-s14">赠品</view>
						<text class="m-l15 f-s14">单价：</text>
					</view>
					<view class="">
						<view class="p-b5 p-l5" style="width: 170rpx;border-bottom: 2rpx solid #999;width: 200rpx;">
							<input type="digit" v-model="Price" class="f-s14 f-w500  box_box"  placeholder="请输入"> 
						</view>
					</view>
					<view class="f-s14 p-l15 p-b5">金额: <text style="color: red;" class="m-l5">{{(Number(Price) * Number(number)).toFixed(2)}}</text></view>
				</view>
				<view class="qujia text-center co_fff f-s14 m-t15" @tap="NeemDiePrys">取价</view>
			</view>
			
			<view class="p-l15 d-flex align-center bg_fff m-t8 f-s14 p-t14 p-b14">
				<view style="width: 120rpx;">备注</view>
				<input type="text" class="f-s14" placeholder="请输入备注">
			</view>
		</view>
		
		
		<view class="b-liuhai" ><view style="height: 84rpx;"></view></view>
		<view style="position: fixed; bottom: 0;width: 100%;z-index: 9;" class="bg_fff">
			<view class="b-liuhai">
				<view class="bg_3A8CFF d-flex align-center justify-content-center" style="height: 84rpx;" @tap="submit">
					<view class="">
						<view class="co_fff f-s14 f-w400">保存</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:['袋','中组','件'],
				count:0,
				index:0,
				array:['主仓','副仓'],
				stauts:false,
				BusinessTypeCode:15,
				CustomerCode:'07970631',
				InventoryCode:'010100003',
				UnitName:'袋',
				Quantity:1,
				number:0,
				Price:0,
				RetailPriceNew:0,
				Name:'',
				IsPresent:false,
				money:'',
				Id:'',
				partnerCode:'',
				Code:'',
			}
		},
		onLoad(e) {
			if(e.data) {
				let data = JSON.parse(e.data)
				this.Id = data.id
				this.Code = data.code
				this.number = data.number
				this.Name = data.name
				this.Price = data.Price
				this.UnitName = data.UnitName
				this.list = data.partnerUnitPrice
				if(data.isPresent) {
					this.IsPresent = true
				}else {
					this.IsPresent = false
				}
				this.list.forEach((e,index) => {
					if(e.UnitName == data.UnitName) {
						this.count = index
					}
				})
			}
			if(e.partnerCode) {
				this.partnerCode = e.partnerCode
			}
			if(e.stauts) {
				this.stauts = e.stauts
			}
		},
		methods: {
			// 取价
			NeemDiePrys() {
				let resData = {
					"invCode": this.Code,
					"partnerCode": this.partnerCode,
					"unitName": this.UnitName
					// "unitCode": this.Code,
				}
				this.$http.post('ApiSA/GetNewSalePrice',resData,true).then(res => {
					if(res.statusCode = 200) {
						if(res.data) {
							this.Price = res.data.taxPrice
							console.log(res.data.taxPrice)
						}
					}
				})
			},
			bindPickerChange(e) {
				this.index = e.detail.value
			},
			// 销售单位切换
			unitsClick(k,item) {
				this.count = k
				this.Price = this.list[k].Price
				this.UnitName = this.list[k].UnitName
			},
			submit() {
				var pages = getCurrentPages();
				var prevPage = pages[pages.length - 2]; //上一个页面
				prevPage.$vm.commodity = {
					id:this.Id,
					Price: this.Price,
					UnitName: this.list[this.count].UnitName,
					number: this.number,
					isPresent:this.IsPresent,
					Code:this.Code
				}
				this.$common.show('保存成功')
				setTimeout(() => {
					uni.navigateBack()
				},1000)
			}
		}
	}
</script>


<style lang="scss">
	page{
		background: #F3F2F7;
	}
	.daiClass{
		padding: 0 20rpx;
		height: 60rpx;
		box-sizing: border-box;
		background-color: #F7F7F7;
	}
	.countClass{
		border: 2rpx solid #64acff;
		background: #fff;
		color: #64acff;
	}
	.qujia{
		width: 360rpx;
		height: 60rpx;
		border-radius: 12rpx;
		line-height: 60rpx;
		background: #3C8CFF;
		margin: 0 auto;
	}
</style>